package com.atguigu.spzx.common.exception;


import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 统一异常处理类
 *
 * @author Henry
 * @version 1.0
 * @program: spzx-parent
 * @create: 2025/6/8 下午3:23
 */

@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 全局异常处理器
     * @param e
     * @return
     */
    @ExceptionHandler(value = Exception.class)
    public Result error(Exception e) {
        e.printStackTrace();
        return Result.build(null , ResultCodeEnum.SYSTEM_ERROR) ;
    }

    /**
     * 自定义异常处理器
     * @param e
     * @return
     */
    @ExceptionHandler(value = GuiguException.class)
    public Result error(GuiguException e) {
        return Result.build(null , e.getResultCodeEnum()) ;
    }



}
